#ifndef Reference_First
#define Reference_First
#ifdef __GNUG__
#pragma interface
#endif

#include "Object.h"

class Class;

enum RefFlags {
	eRefDeleted     =   BIT(eObjLast+1),
	eRefGlobal      =   BIT(eObjLast+2),
	eRefLenGlobal   =   BIT(eObjLast+3),
	eRefLast        =   eObjLast + 3
};

//---- Ref ---------------------------------------------------------------------

class Ref : public Object {
	int type, offset, len;
	Class *cla;
	void *base;

public:
	MetaDef(Ref);

	Ref();
	Ref(void *base, int type, int offset, int len, Class *c, bool global= FALSE,
														bool lenglobal= FALSE);
	Ref(Object *&op);
	Ref(Object &op);
	Ref(const Ref &ref);

	bool IsEqual(Object *op);
	void operator=(Ref r);

	bool IsGlobal()
		{ return TestFlag(eRefGlobal); }
	void *Addr();
	Class *GetClass()
		{ return cla; }
	int GetType()
		{ return type; }
	int GetLen()
		{ return len; }
	bool IsObject();
	Object *GetObject()
		{ return IsObject() ? (Object*) base : 0; }
	int Length();
	bool CanDeref()
		{ return IsObject() || type; }
	Ref *Deref();
	void *GetBase()
		{ return base; }
	char *Value(char *name);
	int Size();
};

#endif

